home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1453.dms / var1453.adf / AmigaDOS / Example6.c < prev    next >
C/C++ Source or Header  |  1992-05-02  |  2KB  |  76 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM System                  Amiga C Club       */
  7. /* Chapter: AmigaDOS                    Tulevagen 22       */
  8. /* File:    Example6.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-02                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This example demonstrates how to protect and unprotect files. */
  21. /* The file Example 5 created ("Letter.doc") will be protected,  */
  22. /* and we will then try to delete it (unsuccessfully). We will   */
  23. /* then unprotect the file and then try to delete it             */
  24. /* (successfully).                                               */  
  25.  
  26.  
  27. /* Declares BOOL: */
  28. #include <exec/types.h>
  29. /* Declares the FileHandle structure: */
  30. #include <libraries/dos.h>
  31.  
  32.  
  33. void main();
  34.  
  35. void main()
  36. {
  37.   BOOL ok;
  38.  
  39.  
  40.   /* Protect the file: */
  41.   ok = SetProtection( "RAM:Letter.doc", FIBF_DELETE );
  42.  
  43.   /* Check if the file was successfully protected: */
  44.   if( !ok )
  45.     printf( "Could not protect the file!\n" );
  46.  
  47.  
  48.   /* Try to delete the file: */
  49.   ok = DeleteFile( "RAM:Letter.doc" );
  50.  
  51.   /* Check if the file was successfully deleteted: */
  52.   if( !ok )
  53.     printf( "Could not delete the file!\n" );
  54.   else
  55.     printf( "File deleted!\n" );
  56.  
  57.  
  58.  
  59.   /* Unprotect the file: */
  60.   ok = SetProtection( "RAM:Letter.doc", NULL );
  61.  
  62.   /* Check if the file was successfully unprotected: */
  63.   if( !ok )
  64.     printf( "Could not unprotect the file!\n" );
  65.  
  66.  
  67.   /* Try to delete the file: */
  68.   ok = DeleteFile( "RAM:Letter.doc" );
  69.  
  70.   /* Check if the file was successfully deleteted: */
  71.   if( !ok )
  72.     printf( "Could not delete the file!\n" );
  73.   else
  74.     printf( "File deleted!\n" );
  75. }
  76.